package com.cos.lession72.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author: COS
 * @time: 2022/9/28 14:43
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class User {
    private Integer id;
    private Integer age;
    @JSONField(name = "username",serialzeFeatures = SerializerFeature.WriteNullStringAsEmpty)
    private String name;
    // 忽略不参与序列化操作
    @JSONField(serialize = false)
    private String sex;
    private Double salary;
    /**
     * 日期需要使用 spring 注解 设置日期格式
     * 接受字符串的日期类型的参数时,帮助我们自己进行转换为date
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JSONField(format = "yyyy-MM-dd hh:mm:ss")
    private Date time;

}
